#!/bin/bash

RESOLV_CONF="/etc/resolv.conf"
NAMESERVER="nameserver 8.8.8.8"

# 检查是否已经存在nameserver配置
if grep -q "^nameserver" "$RESOLV_CONF"; then
    echo "nameserver已存在，跳过添加步骤！"
else
    # 在文件末尾添加nameserver配置
    echo "$NAMESERVER" | sudo tee -a "$RESOLV_CONF" >/dev/null
    echo "nameserver已成功添加！"
fi